/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ReporteUso.java
 *
 * Created on 05-nov-2011, 15:54:57
 */
package presentacion;


/**
 * 
 * @author Manuelita
 */
public class ReporteUso extends javax.swing.JFrame {

    GraficoBarras ventana = new GraficoBarras();

    /** Creates new form ReporteUso */
    public ReporteUso() {
        initComponents();
        setLocationRelativeTo(null);
        CBRangoAno.setVisible(false);
        CBRangoMes.setVisible(false);
        CBRangoSemestre.setVisible(false);
        LRangoAno.setVisible(false);
        LRangoMes.setVisible(false);
        LRangoSemestre.setVisible(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        BGRangoTiempo = new javax.swing.ButtonGroup();
        BGSeleccionFiltro = new javax.swing.ButtonGroup();
        RBCarrera = new javax.swing.JRadioButton();
        RBAno = new javax.swing.JRadioButton();
        RBFacultad = new javax.swing.JRadioButton();
        RBSemestre = new javax.swing.JRadioButton();
        RBUnidadAcademica = new javax.swing.JRadioButton();
        RBMes = new javax.swing.JRadioButton();
        RBSemana = new javax.swing.JRadioButton();
        RBDia = new javax.swing.JRadioButton();
        LRangoTiempo = new javax.swing.JLabel();
        BRUAceptar = new javax.swing.JToggleButton();
        RBSegmentoDia = new javax.swing.JRadioButton();
        LBusquedaReporte = new javax.swing.JLabel();
        LRangoAno = new javax.swing.JLabel();
        LRangoMes = new javax.swing.JLabel();
        LRangoSemestre = new javax.swing.JLabel();
        CBRangoAno = new javax.swing.JComboBox();
        CBRangoMes = new javax.swing.JComboBox();
        CBRangoSemestre = new javax.swing.JComboBox();
        btn_Cancelar = new javax.swing.JToggleButton();

        setTitle("Reporte Uso");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setName("FReporteUso"); // NOI18N

        BGSeleccionFiltro.add(RBCarrera);
        RBCarrera.setLabel("Carrera");

        BGRangoTiempo.add(RBAno);
        RBAno.setLabel("Año");
        RBAno.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RBAnoActionPerformed(evt);
            }
        });

        BGSeleccionFiltro.add(RBFacultad);
        RBFacultad.setLabel("Facultad");

        BGRangoTiempo.add(RBSemestre);
        RBSemestre.setLabel("Semestre");
        RBSemestre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RBSemestreActionPerformed(evt);
            }
        });

        BGSeleccionFiltro.add(RBUnidadAcademica);
        RBUnidadAcademica.setLabel("Unidad Académica");

        BGRangoTiempo.add(RBMes);
        RBMes.setLabel("Mes");
        RBMes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RBMesActionPerformed(evt);
            }
        });

        BGSeleccionFiltro.add(RBSemana);
        RBSemana.setActionCommand("Semana");
        RBSemana.setLabel("Semana");

        BGSeleccionFiltro.add(RBDia);
        RBDia.setLabel("Día");

        LRangoTiempo.setText("Seleccione un rango de tiempo para dar el reporte de uso:");

        BRUAceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/presentacion/imagenes/Aceptar.png"))); // NOI18N
        BRUAceptar.setLabel("Aceptar");
        BRUAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BRUAceptarActionPerformed(evt);
            }
        });

        BGSeleccionFiltro.add(RBSegmentoDia);
        RBSegmentoDia.setLabel("Segmento Día");

        LBusquedaReporte.setText("Seleccione una opción para realizar la busqueda del reporte de uso:");

        LRangoAno.setText("Año:");

        LRangoMes.setText("Mes:");

        LRangoSemestre.setText("Semestre:");

        CBRangoAno.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2011" }));

        CBRangoMes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Setiembre", "Octubre", "Noviembre", "Diciembre" }));

        CBRangoSemestre.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "I ciclo", "II clclo" }));

        btn_Cancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/presentacion/imagenes/Cancelar.png"))); // NOI18N
        btn_Cancelar.setText("Cancelar");
        btn_Cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_CancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(50, 50, 50)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(RBMes)
                        .addGap(59, 59, 59)
                        .addComponent(RBSemestre)
                        .addGap(52, 52, 52)
                        .addComponent(RBAno))
                    .addComponent(LRangoTiempo)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addGap(26, 26, 26)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(RBCarrera)
                                .addComponent(RBFacultad))
                            .addGap(61, 61, 61)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(RBUnidadAcademica)
                                .addComponent(RBSegmentoDia))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(RBSemana)
                                .addComponent(RBDia)))
                        .addComponent(LBusquedaReporte, javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addComponent(LRangoAno)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(CBRangoAno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(33, 33, 33)
                            .addComponent(LRangoMes)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(CBRangoMes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(32, 32, 32)
                            .addComponent(LRangoSemestre)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(CBRangoSemestre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(45, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(147, Short.MAX_VALUE)
                .addComponent(btn_Cancelar)
                .addGap(40, 40, 40)
                .addComponent(BRUAceptar)
                .addGap(53, 53, 53))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(LRangoTiempo)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(RBAno)
                    .addComponent(RBSemestre)
                    .addComponent(RBMes))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(LRangoAno)
                    .addComponent(LRangoMes)
                    .addComponent(LRangoSemestre)
                    .addComponent(CBRangoMes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(CBRangoSemestre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(CBRangoAno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE)
                .addComponent(LBusquedaReporte)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(RBCarrera)
                        .addGap(18, 18, 18)
                        .addComponent(RBFacultad))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(RBUnidadAcademica)
                        .addGap(18, 18, 18)
                        .addComponent(RBSegmentoDia))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(RBDia)
                        .addGap(18, 18, 18)
                        .addComponent(RBSemana)))
                .addGap(39, 39, 39)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BRUAceptar)
                    .addComponent(btn_Cancelar))
                .addGap(44, 44, 44))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void BRUAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BRUAceptarActionPerformed

    if (RBMes.isSelected()) {
        //  ventana.setSemestreMes(CBRangoMes.getName());
        ventana.setAno("2011" /*CBRangoAno.getName()*/);
    } else {
        if (RBAno.isSelected()) {
            ventana.setAno("2011" /*CBRangoAno.getName()*/);
        } else {
            if (RBSemestre.isSelected()) {
                //ventana.setSemestreMes(CBRangoSemestre.getName());
                ventana.setAno("2011" /*CBRangoAno.getName()*/);
            }
        }
    }


    if (RBCarrera.isSelected()) {
        ventana.setTipo("Carrera");
        for (int i = 0; i < 50; i++) {
            agregarDato("Ingenieria en Sistemas");
            agregarDato("Adminsitración");
            agregarDato("Psicología");
            agregarDato("Economía");
            agregarDato("Química");
        }
    } else {
        if (RBFacultad.isSelected()) {
            ventana.setTipo("Facultad");
            for (int i = 0; i < 50; i++) {
                agregarDato("Ciencias Sociales");
                agregarDato("Exactas y Naturales");
                agregarDato("Filosofía y Letras");
                agregarDato("Tierra y Mar");
                agregarDato("CIDE");
                agregarDato("CIDEA");
                agregarDato("Ciencias de la Salud");
            }
        } else {
            if (RBUnidadAcademica.isSelected()) {
                ventana.setTipo("Unidad Académica");
            } else {
                if (RBSegmentoDia.isSelected()) {
                    ventana.setTipo("Segmento del día");
                    for (int i = 0; i < 50; i++) {
                        agregarDato("Mañana");
                        agregarDato("Tarde");
                        agregarDato("Noche");
                        agregarDato("Mediodía");
                    }
                } else {
                    if (RBDia.isSelected()) {
                        ventana.setTipo("Día");
                        for (int i = 0; i < 50; i++) {
                            agregarDato("Lunes");
                            agregarDato("Martes");
                            agregarDato("Miercoles");
                            agregarDato("Jueves");
                            agregarDato("Viernes");
                        }
                    } else {
                        if (RBSemana.isSelected()) {
                            ventana.setTipo("Semana");
                        }
                    }
                }
            }
        }
    }

    ventana.setSize(650, 650);
    ventana.repaint();
    ventana.setVisible(true);
}//GEN-LAST:event_BRUAceptarActionPerformed

/**
 * 
 * @param _dato
 */
public void agregarDato(String _dato) {
        if (ventana.getDatos().get(_dato) == null) {
            ventana.getDatos().put(_dato, "1");
        } else {
            String y = (String) ventana.getDatos().get(_dato);
            ventana.getDatos().put(_dato, "" + (Integer.parseInt(y) + 1));
        }
    }

private void RBMesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RBMesActionPerformed
    CBRangoAno.setVisible(true);
    CBRangoMes.setVisible(true);
    CBRangoSemestre.setVisible(false);
    LRangoAno.setVisible(true);
    LRangoMes.setVisible(true);
    LRangoSemestre.setVisible(false);
}//GEN-LAST:event_RBMesActionPerformed

private void RBSemestreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RBSemestreActionPerformed
    CBRangoAno.setVisible(true);
    CBRangoMes.setVisible(false);
    CBRangoSemestre.setVisible(true);
    LRangoAno.setVisible(true);
    LRangoMes.setVisible(false);
    LRangoSemestre.setVisible(true);
}//GEN-LAST:event_RBSemestreActionPerformed

private void RBAnoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RBAnoActionPerformed
    CBRangoAno.setVisible(true);
    CBRangoMes.setVisible(false);
    CBRangoSemestre.setVisible(false);
    LRangoAno.setVisible(true);
    LRangoMes.setVisible(false);
    LRangoSemestre.setVisible(false);
}//GEN-LAST:event_RBAnoActionPerformed

private void btn_CancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_CancelarActionPerformed
    setVisible(false);
}//GEN-LAST:event_btn_CancelarActionPerformed
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup BGRangoTiempo;
    private javax.swing.ButtonGroup BGSeleccionFiltro;
    private javax.swing.JToggleButton BRUAceptar;
    private javax.swing.JComboBox CBRangoAno;
    private javax.swing.JComboBox CBRangoMes;
    private javax.swing.JComboBox CBRangoSemestre;
    private javax.swing.JLabel LBusquedaReporte;
    private javax.swing.JLabel LRangoAno;
    private javax.swing.JLabel LRangoMes;
    private javax.swing.JLabel LRangoSemestre;
    private javax.swing.JLabel LRangoTiempo;
    private javax.swing.JRadioButton RBAno;
    private javax.swing.JRadioButton RBCarrera;
    private javax.swing.JRadioButton RBDia;
    private javax.swing.JRadioButton RBFacultad;
    private javax.swing.JRadioButton RBMes;
    private javax.swing.JRadioButton RBSegmentoDia;
    private javax.swing.JRadioButton RBSemana;
    private javax.swing.JRadioButton RBSemestre;
    private javax.swing.JRadioButton RBUnidadAcademica;
    private javax.swing.JToggleButton btn_Cancelar;
    // End of variables declaration//GEN-END:variables
}
